<!--<?php
include_once PrintEot('header');
if($action=="showmercontract"){
print <<<EOT
-->
<select id="contract_id" name="contract_id" style="width:202px">$op_mercontractlist</select>需要先选择“所属客户”,该客户下的所有合同将自动显示
<!--
EOT;
}else if($action=="new" || $action=="edit"){
print <<<EOT
-->
<form name="form" id="form" action="$basename" method="post" onsubmit="return checkfrm();">
<input type="hidden" name="action" id="action" value="save"/>
<input type="hidden" name="job" id="job" value="$job"/>
<input type="hidden" name="curid" id="curid" value="$curid"/>
<TABLE cellSpacing="0" cellPadding="0" width="100%" border=0 ID="Table22">
	<TBODY>
		<TR >
			<TD class="tittab" BACKGROUND="$imgpath/admin/menu_bg.gif"><strong><img src="$imgpath/admin/view.gif" width="15" height="13" align="absmiddle"> 新增/编辑　服务商回款</strong></TD>
		</TR>
	</TBODY>
</TABLE>
<table cellspacing=0 cellpadding=0 width="100%" border=0 id="Table23">  
    <tbody>
      <tr>
        <td valign=top>
		<div class="addpro">
		<table cellspacing=0 cellpadding=4 width="100%" border=0 align=center id="Table24">
        <tbody>
        <tr>
					<td align=right width=20%>所属客户(<font color="red">*</font>)：</td>
					<td style="width: 322px">
						<select ID="mer_id" name="mer_id" style="width:202px" onchange="showMerContract(this);"><option value="">请选择...</option>$op_merchantlist</select>				    
					</td>
				
					<td align=right width=100>对应合同(<font color="red">*</font>)：</td>
					<td id="divContract"><select ID="contract_id" name="contract_id" style="width:202px"><option value="">请选择...</option>$op_mercontractlist</select>需要先选择“所属客户”,该客户下的所有合同将自动显示</td>
				</tr>
				<tr>
					<td align=right>计划回款金额(<font color="red">*</font>)：</td>
					<td style="width: 322px">
					    <input type="text" id="plan_money" name="plan_money" style="WIDTH: 101px" value="$db_merpayrec[plan_money]"/> 元
					</td>
				
					<td align=right>实际回款金额：</td>
					<td>
					    <input type="text" id="real_money" name="real_money" style="WIDTH: 101px" value="$db_merpayrec[real_money]"/> 元
					</td>
				</tr>
				<tr>
					<td align=right>计划回款时间：</td>
					<td>
					    <input name="plan_paydate" type="text" readonly id="plan_paydate" value="$db_merpayrec[plan_paydate]" style="WIDTH:102px"><A href="javascript:OpenCalendar('plan_paydate', false)"><IMG src="$imgpath/admin/icon-calendar.gif" align="absMiddle" border="0"></A>
					</td>
					<td align=right>实际回款时间：</td>
					<td>
					    <input name="real_paydate" type="text" readonly id="real_paydate" value="$db_merpayrec[real_paydate]" style="WIDTH:102px"><A href="javascript:OpenCalendar('real_paydate', false)"><IMG src="$imgpath/admin/icon-calendar.gif" align="absMiddle" border="0"></A>
					</td>					
				</tr>
				<tr>				
					<td align=right>对帐编号：</td>
					<td style="width: 322px"><input type="text" id="fin_no" name="fin_no" value="$db_merpayrec[fin_no]" style="WIDTH: 101px"></td>
				    <td align=right>开票时间：</td>
					<td><input name="ticket_time" type="text" readonly id="ticket_time" value="$db_merpayrec[ticket_time]" style="WIDTH:102px"><A href="javascript:OpenCalendar('ticket_time', false)"><IMG src="$imgpath/admin/icon-calendar.gif" align="absMiddle" border="0"></A></td>					
				</tr>
				<tr>				
					<td align=right>确认回款人：</td>
					<td style="width: 322px"><select id="sure_id" name="sure_id" style="WIDTH: 101px"><option value="">请选择...</option>$op_surelist</select></td>
					<td align=right>确认回款时间：</td>
					<td><input name="pay_time" type="text" readonly id="pay_time" value="$db_merpayrec[pay_time]" style="WIDTH:102px"><A href="javascript:OpenCalendar('pay_time', false)"><IMG src="$imgpath/admin/icon-calendar.gif" align="absMiddle" border="0"></A></td>
				</tr>
				<tr>
					<td align=right>状态：</td>
					<td colspan=3>
<!--
EOT;
	if(!isset($db_merpayrec) || $db_merpayrec[status]==0){
		echo '<input type="radio" ID="status0" name="status" value="0" checked/><label for="status0">未开发票</label>';
	}else{
		echo '<input type="radio" ID="status0" name="status" value="0"/><label for="status0">未开发票</label>';
	}
	if($db_merpayrec[status]==1){
		echo '<input type="radio" ID="status1" name="status" value="1" checked/><label for="status1">已开发票</label>';
	}else{
		echo '<input type="radio" ID="status1" name="status" value="1"/><label for="status1">已开发票</label>';
	}
	if($db_merpayrec[status]==2){
		echo '<input type="radio" ID="status2" name="status" value="2" checked/><label for="status2">对方收到发票,打款中</label>';
	}else{
		echo '<input type="radio" ID="status2" name="status" value="2"/><label for="status2">对方收到发票,打款中</label>';
	}
	if($db_merpayrec[status]==3){
		echo '<input type="radio" ID="status3" name="status" value="3" checked/><label for="status3">发票有误,重开发票</label>';
	}else{
		echo '<input type="radio" ID="status3" name="status" value="3"/><label for="status3">发票有误,重开发票</label>';
	}
	if($db_merpayrec[status]==4){
		echo '<input type="radio" ID="status4" name="status" value="4" checked/><label for="status4">款已到</label>';
	}else{
		echo '<input type="radio" ID="status4" name="status" value="4"/><label for="status4">款已到</label>';
	}
print <<<EOT
-->(选择“款已到”后此条记录不再可编辑，且“实际金额”会增加到该广告主的已留存金额中)
					</td>
				</tr>
				<tr>
					<td align=right style="height: 57px">回款说明：</td>
					<td colspan=3 style="height: 57px">
					<textarea ID="memo" style="Height:51px;Width:431px"></textarea>
					</td>
				</tr>
				
				<tr>
					<td colspan="4" align="center">
					<input type="submit" id="btnSubmit" value=" 确定 " NAME="btnSubmit">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
					<input type="button" onclick="history.go(-1);" value=" 取消 ">
					</td>
				</tr>
         
    </tbody>

 </TABLE>
 </div>
 </td>
 </tr>
 </tbody>
 </table>
 </form>
<script type="text/javascript" language=javascript>
function checkfrm(){
	if(isEmpty($("mer_id").value)){
		alert('请选择所属客户！');
		$("mer_id").focus();
        return false;
	}
	if(isEmpty($("contract_id").value)){
		alert('请选择对应合同！');
		$("mer_id").focus();
        return false;
	}	
	if(isEmpty($("plan_money").value)){
		alert('请输入计划回款金额！');
		$("plan_money").focus();
		return false;
	}else if(isNaN($("plan_money").value)){
	    alert('计划回款金额必须为数字！');
	    $("plan_money").focus();
		return false;
	}
	if(isEmpty($("real_money").value)==false){
		if(isNaN($("real_money").value)){
		    alert('实际回款金额必须为数字！');
		    $("real_money").focus();
			return false;
		}
	}
    return true;
}

</script>

<!--
EOT;
}else{
print <<<EOT
-->
<form action="$admin_file" method="post" name="form">

    <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
            <td align="left" class="tittab">
                <strong>广告主管理 &gt;&gt; 回款管理</strong>
            </td>
        </tr>
    </table>
    <table id="Table50" border="0" cellpadding="0" cellspacing="1" width="98%" align=center>
        <tr>
            <td colspan=2 height=30 class="zmenu"><b>数据分类：</b>
<!--
EOT;
 showPageLink("all", "1", "全部");
 showPageLink("status", "0", "未开发票");
 showPageLink("status", "1", "已开发票");
 showPageLink("status", "2", "对方收到发票,打款中");
 showPageLink("status", "3", "发票有误,重开发票");
 showPageLink("status", "4", "款已到");
print <<<EOT
-->            
            </td></tr>
         <tr>
            <td><b>快速查询：</b><select name="searchtype">
								<option value="contractname" selected>合同主题</option>
								<option value="shortname">客户简称</option>
								<option value="ticketor_user">开票人</option>
								<option value="fin_no">对帐编号</option>
								<option value="memo">回款说明</option>							
							</select>
							<input type="text" name="searchkey" class="text" value=""/>
							<input type="button" value="查询" class="text"/>
						</td>
            <td align="right" valign="center">
                <table id="Table51" border="0" cellpadding="0" cellspacing="5" height="30">
                    <input id="Hidden1" name="allSelect" type="hidden" value="all" />
                    <tr>
                        <td align="middle" valign="center">
                            <a href="javascript:document.location.reload();">
                                <img align="absMiddle" border="0" height="15" src="$imgpath/admin/reserch.gif" style="text-decoration: underline" width="17" />
                                <span style="color: #547054"> 刷新</span></a>
<!--
EOT;
	if($canadd==true){
		showButton(1,'新增',$admin_file.'&action=new'.$transtr);
	}
	if($candel==true){
		showButton(2,'删除','javascript:ConfirmDel("'.$admin_file.'&action=del'.$transtr.'&curpage='.$curpage.'","此操作不可恢复,确认删除吗？");');
	}
print <<<EOT
-->
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td height="2">
            </td>
        </tr>
    </table>
    <div class="tab">
        <table id="Table52" border="0" cellpadding="3" cellspacing="0" align=center>
            <tr>
                <td align="middle" class="title" height="20" valign="center">序号</td>
                <td align="middle" class="title" height="20" valign="center">
                    <input id="Checkbox1" name="as" onclick="allchecked()" type="checkbox" />全选
                </td>
                <td align="middle" class="title" height="20" valign="center">合同名称</td>
                <td align="middle" class="title" height="20" valign="center">合同金额</td>                
                 <td align="middle" class="title" height="20" valign="center">对应客户</td>
                <td align="middle" class="title" height="20" valign="center">计划金额</td>
                <td align="middle" class="title" height="20" valign="center">实际金额</td>                 
                <td align="middle" class="title" height="20" valign="center">对帐编号</td> 
                 <td align="middle" class="title" height="20" valign="center">确认回款人</td>               
                <td align="middle" class="title" height="20" valign="center">状态</td>                
                <td align="middle" class="title" height="20" valign="center">操作</td>
            </tr>
<!--
EOT;
$curidx = ($curpage-1)*$perpage;
$curpageidx = 0;
$showcount = count($db_merpayreclist); 
foreach($db_merpayreclist as $merpay ){
	$curidx = $curidx+1;
	$curpageidx = $curpageidx+1;
	$cdate = date('Y/m/d H:i:s',$merpay[create_time]);
	$status = $cfg_merpayrecstatus[$merpay[status]];
print <<<EOT
-->      
            <tr height="20" onclick="SwitchTd(this,'click',$curpageidx);" onmouseout="SwitchTd(this,'out',$curpageidx);" onmouseover="SwitchTd(this,'over',$curpageidx);" style="cursor: hand">
                <td align="middle" valign="center" height="20">$curidx </td>
                <td align="middle" valign="center">
                    <input id="ids" name="ids" type="checkbox" value="$merpay[id]" />
                </td>
                <td align="middle" valign="center">&nbsp;$merpay[contract_name]</td>
                <td align="middle" valign="center">&nbsp;$merpay[contract_fee]千元</td>                
                <td align="middle" valign="center">&nbsp;<a href="$basename?job=detail&action=merchant&curid=$merpay[id]&backurl=$backurl">$merpay[mer_name]</a></td>
                <td align="middle" valign="center">&nbsp;$merpay[plan_money]</td>
                <td align="middle" valign="center">&nbsp;$merpay[real_money]</td>
                <td align="middle" valign="center">&nbsp;$merpay[fin_no]</td>
                <td align="middle" valign="center">&nbsp;$merpay[sure_user]</td>
                <td align="middle" valign="center">&nbsp;$status</td>
                <td align="middle" valign="center">&nbsp;
<!--
EOT;
if($merpay[status]!=4){
	showEditButton($merpay[id]);
}else{
	echo '款已到，不可编辑';
}
print <<<EOT
-->
                </td>
            </tr>
<!--
EOT;
}print <<<EOT
-->
        </table>
    </div>
    <table id="Table1" border="0" cellpadding="0" cellspacing="0" width="98%">
        <tr>
            <td>
                &nbsp;</td>
            <td align="right" height="35">
<!--
EOT;
	showPageBreakInfo($showcount);
print <<<EOT
-->
             &nbsp;</td>
        </tr>
    </table>
    <input type="hidden" id="count" name="count" value="$showcount" />

</form>

<!--
EOT;
}?>-->